package com.ossjk.oa.accounting.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.ossjk.oa.accounting.entity.CwSalary;
import com.ossjk.oa.attendance.vo.SalaryAttVo;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author chair
 * @since 2020-05-14
 */
public interface CwSalaryMapper extends BaseMapper<CwSalary> {
	
	List selectVoPage(Page page, @Param("ew") Wrapper wrapper);
	
	@Select("SELECT s.id,s.wagemonth as mth,s.attendance as attc,s.actualattendance as actattc,s.breakoff as brkoff,s.leaved as leaved, " + 
			"   s.late as late,s.overtime as ovrtm  ,s.absenteeism as absm  ,s.missedpunching as misdch  ,e.name as enm,  " + 
			"   d.name as dptname,  s.crtm,s.state  from cw_salary s,employee e,department d,post p,employee_post ep " + 
			" where s.empid = e.id and p.did=d.id and p.id =ep.pid and ep.eid=e.id and left(s.wagemonth,7)=#{mth} and e.id=#{eid}")
	SalaryAttVo selectSalaryAttvByEid( @Param("eid")String eid, @Param("mth") String mth);
	
	@Select("SELECT s.id,s.wagemonth as mth,s.attendance as attc,s.actualattendance as actattc,s.breakoff as brkoff,s.leaved as leaved, " + 
			"   s.late as late,s.overtime as ovrtm  ,s.absenteeism as absm  ,s.missedpunching as misdch  ,e.name as enm,  " + 
			"   d.name as dptname,  s.crtm,s.state  from cw_salary s,employee e,department d,post p,employee_post ep " + 
			" where s.empid = e.id and p.did=d.id and p.id =ep.pid and ep.eid=e.id and left(s.wagemonth,7)=#{mth} and d.id=#{did} ")
	List<SalaryAttVo> selectSalaryAttvByDept( @Param("did")String did, @Param("mth") String mth);
	
	
}
